Skip to content

Conversation

InfiniteXyy
Copy link
Contributor

This PR is based on #1019.

In React 18, external state management may not work due to concurrent mode. To sync state, we have to use the useSyncExternalStore hook.

Luckily, React officially provides a lib, https://www.npmjs.com/package/use-sync-external-store, to ship support for both React 17 and 18.

In this PR, I installed that hook, and made some refactoring to compat the use-sync-external-store API. All the test cases and ts defination have not been changed.

@codecov
Copy link

codecov bot commented Jun 14, 2022

Codecov Report

Merging #1020 (5c4a0ee) into master (ea4aca7) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #1020   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           51        57    +6     
  Branches         6         5    -1     
=========================================
+ Hits            51        57    +6     
Impacted Files Coverage Δ
src/use-event-callback.ts 100.00% <100.00%> (ø)
src/use-observable.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea4aca7...5c4a0ee. Read the comment docs.

@Miloas
Copy link
Contributor

Miloas commented Jun 19, 2022

LGTM!

@Miloas Miloas merged commit c3b2ec7 into LeetCode-OpenSource:master Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants